package cn.blunce.mylib;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import cn.blunce.base.DBTest;
import cn.blunce.qq_interface.QQ_interface;
import cn.blunce.utils.AsyncTaskHelper.AsyncTaskTest;
import cn.blunce.utils.ScreenHelper.ScreenTest;
import cn.blunce.utils.Timer.TimerTest;
import cn.blunce.utils.XmlParse.XstreamTestActivity;
import cn.blunce.utils.bluetooth.BlueToothTest;
import cn.blunce.view_utils.ChartHelp.DrawPic;
import cn.blunce.view_utils.ListViewHelp.ListViewTest;
import cn.blunce.view_utils.PopWindowHelper.PopWindowTest;
import cn.blunce.view_utils.ViewPagerHelper.ViewPagerTest;

public class MainActivity extends Activity implements AdapterView.OnItemClickListener {

    private List<Intent> intents;
    private List<String> intentNames;

    private ListView showIntents;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        showIntents = (ListView) findViewById(R.id.show_intent);
        initList();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, intentNames);
        showIntents.setAdapter(adapter);
        showIntents.setOnItemClickListener(this);
    }

    private void initList() {
        intents = new ArrayList<Intent>();
        intentNames = new ArrayList<String>();

        //ViewPager使用
        Intent intent = new Intent(this, ViewPagerTest.class);
        intents.add(intent);
        intentNames.add("ViewPager使用");

        //数据库使用
        intent = new Intent(this, DBTest.class);
        intents.add(intent);
        intentNames.add("数据库使用");

        //获取屏幕参数
        intent = new Intent(this, ScreenTest.class);
        intents.add(intent);
        intentNames.add("获取屏幕参数");

        //展示蓝牙使用
        intent = new Intent(this, BlueToothTest.class);
        intents.add(intent);
        intentNames.add("展示蓝牙使用");

        //仿QQ界面
        intent = new Intent(this, QQ_interface.class);
        intents.add(intent);
        intentNames.add("仿QQ界面");

        //折线图
        intent = new Intent(this, DrawPic.class);
        intents.add(intent);
        intentNames.add("折线图");

        //AsyncTask类的使用
        intent = new Intent(this, AsyncTaskTest.class);
        intents.add(intent);
        intentNames.add("AsyncTask类的使用");

        //ListView和AlertDialog使用
        intent = new Intent(this, ListViewTest.class);
        intents.add(intent);
        intentNames.add("ListView和AlertDialog使用");

        //计时器使用
        intent = new Intent(this, TimerTest.class);
        intents.add(intent);
        intentNames.add("计时器使用");

        //Xstream使用
        intent = new Intent(this, XstreamTestActivity.class);
        intents.add(intent);
        intentNames.add("Xstream使用");

        //PopWindow使用
        intent = new Intent(this, PopWindowTest.class);
        intents.add(intent);
        intentNames.add("PopWindow使用");
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        startActivity(intents.get(position));
    }
}
